package st.business.tepth.business.goods;

import st.business.tepth.base.OnDataConvertListener;

/**
 * Author: shadow
 * Email:  1025431817@qq.com
 * Time:   2019-02-25 15:38
 */

public class GoodsPresenter extends GoodsContract.Presenter {
    private final GoodsContract.View mView;
    private final GoodsContract.Model mModel;

    public GoodsPresenter(GoodsContract.View view) {
        mView = view;
        mModel = new GoodsModel();
    }

    @Override
    void applyGoods(String token, String items) {
        addDisposable(mModel.applyGoods(token, items,
                new OnDataConvertListener<String>() {
                    @Override
                    public void convert(String s) {
                        if (mView != null) {
                            mView.showApplySucceed();
                        }
                    }

                    @Override
                    public void error(int code, String msg) {
                        if (mView != null) {
                            mView.showError(msg);
                        }
                    }
                }));
    }

    @Override
    void waiteApply(String token, String items) {
        addDisposable(mModel.waiteApply(token, items,
                new OnDataConvertListener<String>() {
                    @Override
                    public void convert(String s) {
                        if (mView != null) {
                            mView.showWaiteApplySucceed();
                        }
                    }

                    @Override
                    public void error(int code, String msg) {
                        if (mView != null) {
                            mView.showError(msg);
                        }
                    }
                }));
    }
}
